<template>
    <!-- 过渡图片 -->
    <div class="trans_pic">
        <li>
            <img :src="src1" alt="">
        </li>
        <li>
            <img :src="src2" alt="">
        </li>       
    </div>
    <!-- 精选收藏夹 -->
    <div class="jxxsc">
        <!-- 标题栏 -->
        <div class="title">
            <h5>精选收藏夹</h5>
            <p><a href="#">查看更多</a></p>
        </div>
        <!-- 列表栏 -->
        <div class="jx_list">
            <li v-for="(item,index) in jx_list.value" :key="index">
                <div class="row1">
                    <a href="#">
                        <img :src="item.img" alt="图片">
                        <span class="guanzhu"><a href="#">关注</a></span>
                    </a>
                </div>
                <div class="row2">
                    <a href="#">{{item.name}}</a>
                </div>
                <div class="row3">{{item.type}}</div>
                <div class="row4">
                    <img src="../assets/section_img/img_count.png" alt="图片数量">&nbsp;
                    <span>{{item.img_count}}</span>&emsp;
                    <img src="../assets/section_img/sc.png" alt="收藏量">&nbsp;
                    <span>{{item.sc_count}}</span>
                </div>
            </li>
        </div>
    </div>
    <!-- 推荐课程 -->
    <div class="tjkc">
        <!-- 标题栏 -->
        <div class="title">
            <h5>推荐课程</h5>
            <p><a href="#">换一换</a></p>
        </div>
        <!-- 列表栏 -->
        <div class="tj_list">
            <li v-for="(item,index) in tj_list.value" :key="index">
                <a href="#" class="a1"><img :src="item.img" alt="图片"></a>
                <a href="#" class="a2">{{item.desc}}</a>
            </li>
        </div>
    </div>
</template>
<style lang="scss" scoped>
// 过渡图片样式
.trans_pic{
    margin: auto;
    width: 74%;
    padding-top: 40px;
    display: flex;
    justify-content: space-between;
    li{
        width: 680px;
        height: 115px;
        img{
            width: 100%;
            border-radius: 5px;
        }
    }
}
// 精选收藏夹
.jxxsc{
    width: 74%;
    margin: auto;
    // 标题栏
    .title{
        width: 100%;
        margin-top: 20px;
        display: flex;
        justify-content: space-between;
        h5{
            font-size: 14px;
            color: #666666;

        }
        p{
            a{
                font-size: 14px;
                color: #FF7300;
            }
        }
    }
    // 列表栏
    .jx_list{
        width: 100%;
        margin-top: 20px;
        display: flex;
        justify-content: space-between;
        li{
            background-color: white;
            padding:15px 15px;
            border-radius: 5px;
            .row1{
                width: 100%;
                >a{
                    margin: auto;
                    display: block;
                    height: 182px;
                    border-radius: 5px;
                    transform: all 2s;
                    position: relative;
                    img{
                        width: 100%;
                    }
                    span{
                        display: block;
                        width: 45px;
                        height: 25px;
                        font-size: 12px;
                        background-color: rgb(255,242,0);
                        border-radius: 5px;
                        position:absolute;
                        top:5px;
                        right: 5px;
                        display: none;
                        transform: all 2s;
                        a{
                            color: black;
                            line-height: 25px;
                        }
                    }
                    span:hover{
                        background-color: #FF7300;
                    }
                }
                a:hover{
                    opacity: 0.8;
                }
            }
            .row2{
                width: 100%;
                text-align: left;
                margin-top: 10px;
                a{
                    padding-left: 8px;
                    font-size: 14px;
                    color: #282828;
                }
                a:hover{
                    color: #FF7300;
                }
            }
            .row3{
                width: 60px;
                height: 15px;
                font-size: 12px;
                color: rgb(248, 51, 51);
                background-color: rgb(248, 218, 223);
                border-radius: 2px;
                margin-top: 10px;
                margin-left: 8px;
            }
            .row4{
                width: 100%;
                display: flex;
                justify-content: flex-start;
                margin-top: 20px;
                padding: 0 8px;
                img{
                    width: 16px;
                    height: 16px;
                }
                span{
                    color: #bbbbbb;
                    font-size: 12px;
                    line-height: 16px;
                }
            }
        }
        li:hover .guanzhu{
            display: block;
        }
    }

}
// 推荐课程
.tjkc{
    width: 74%;
    margin: auto;
    padding-bottom: 50px;
    // 标题栏
    .title{
        width: 100%;
        margin-top: 20px;
        display: flex;
        justify-content: space-between;
        h5{
            font-size: 14px;
            color: #666666;

        }
        p{
            a{
                font-size: 14px;
                color: #FF7300;
            }
        }
    }
    // 列表栏
    .tj_list{
        width: 100%;
        margin-top: 20px;
        display: flex;
        justify-content: space-between;
        li{
            width: 260px;
            height: 186px;
            border-radius: 5px;
            background-color: white;
            overflow: hidden;
            a{
                display: block;
                width: 100%;
                font-size: 14px;
                color: #282828;
                transform: all 1.5s;
                img{
                    width: 100%;
                }
            }
            .a1:hover{
                opacity: 0.8;
            }
            .a2{
                line-height: 40px;
                overflow: hidden; /*隐藏*/
                white-space: nowrap;  /*不换行*/
                text-overflow: ellipsis;  /* 超出部分省略号 */
            }
            .a2:hover{
                color: #FF7300;
            }
        }
    }
}
</style>
<script>
import axios from 'axios'
import {ref,reactive} from 'vue'
export default {
    setup(){
        let src1 = ref(require('../assets/section_img/sec1.jpg'))
        let src2 = ref(require('../assets/section_img/sec2.jpg'))
        let jx_list = reactive([])
        
        axios.get("http://127.0.0.1:4523/m1/1231339-0-default/myZcool/jingxuan/1")
        .then((res)=>{
            jx_list.value = res.data.data
        })
        .catch(()=>{
            console.log("not found")
        })
        let tj_list = reactive([])
        axios.get("http://127.0.0.1:4523/m1/1231339-0-default/myZcool/tuijiankecheng/1")
        .then((res)=>{
            tj_list.value = res.data.data
        })
        .catch(()=>{
            console.log("not found")
        })
        return{
            src1,
            src2,
            jx_list,
            tj_list
        }
    }

}
</script>